home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / MFC64bitFix.cpp < prev    next >
C/C++ Source or Header  |  2011-11-06  |  3KB  |  84 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. #include "stdafx.h"
  20.  
  21. #include "MFC64bitFix.h"
  22.  
  23. /*__int64 GetLength64(CFile &file)
  24. {
  25.     DWORD low;
  26.     DWORD high;
  27.     low=GetFileSize((void *)file.m_hFile, &high);
  28.     _int64 size=((_int64)high<<32)+low;
  29.     return size;
  30. }*/
  31.  
  32. BOOL GetLength64(LPCTSTR filename, _int64 &size)
  33. {
  34.     WIN32_FIND_DATA findFileData;
  35.     HANDLE hFind = FindFirstFile(filename, &findFileData);
  36.     if (hFind == INVALID_HANDLE_VALUE)
  37.         return FALSE;
  38.     VERIFY(FindClose(hFind));
  39.  
  40.     size=((_int64)findFileData.nFileSizeHigh<<32)+findFileData.nFileSizeLow;
  41.     
  42.     return TRUE;    
  43. }
  44.  
  45. BOOL PASCAL GetStatus64(LPCTSTR lpszFileName, CFileStatus64& rStatus)
  46. {
  47.     WIN32_FIND_DATA findFileData;
  48.     HANDLE hFind = FindFirstFile((LPTSTR)lpszFileName, &findFileData);
  49.     if (hFind == INVALID_HANDLE_VALUE)
  50.         return FALSE;
  51.     VERIFY(FindClose(hFind));
  52.  
  53.     // strip attribute of NORMAL bit, our API doesn't have a "normal" bit.
  54.     rStatus.m_attribute = (BYTE)
  55.         (findFileData.dwFileAttributes & ~FILE_ATTRIBUTE_NORMAL);
  56.  
  57.     rStatus.m_size = ((_int64)findFileData.nFileSizeHigh<<32)+findFileData.nFileSizeLow;
  58.  
  59.     // convert times as appropriate
  60.     rStatus.m_ctime = findFileData.ftCreationTime;
  61.     rStatus.m_atime = findFileData.ftLastAccessTime;
  62.     rStatus.m_mtime = findFileData.ftLastWriteTime;
  63.  
  64.     if (rStatus.m_ctime.dwHighDateTime == rStatus.m_ctime.dwLowDateTime == 0)
  65.         rStatus.m_ctime = rStatus.m_mtime;
  66.  
  67.     if (rStatus.m_atime.dwHighDateTime == rStatus.m_atime.dwLowDateTime == 0)
  68.         rStatus.m_atime = rStatus.m_mtime;
  69.  
  70.     return TRUE;
  71. }
  72.  
  73. _int64 GetPosition64(HANDLE hFile)
  74. {
  75.     if (!hFile || hFile==INVALID_HANDLE_VALUE)
  76.         return -1;
  77.     LONG low=0;
  78.     LONG high=0;
  79.     low=SetFilePointer(hFile, low, &high, FILE_CURRENT);
  80.     if (low==0xFFFFFFFF && GetLastError!=NO_ERROR)
  81.         return -1;
  82.     return ((_int64)high<<32)+low;
  83. }
  84.